package org.jwcloud.project.module.zx.common.service;

import java.io.IOException;
import java.util.HashMap;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class MybatisSessionUtil {

    static SqlSessionFactory sqlSessionFactory = null;
    
    static{
        SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();
        try {
            sqlSessionFactory = sqlSessionFactoryBuilder.build(Resources.getResourceAsStream("mybatis-config.xml"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    public static SqlSession getSession(){
    	System.out.println(sqlSessionFactory);
        return sqlSessionFactory.openSession();
    }
    
    public static void main(String[] args) {
    	SqlSession sql = getSession();
    	Object obj = sql.selectList("org.jwcloud.project.module.zx.template.service.repository.RptManTipRepository.queryDbList", new HashMap());
    	System.out.println(obj);
	}
    
}